<?php
namespace app\oa\controller;

use app\oa\ext\UserStatus;
use think\Controller;

abstract class Role extends Controller {
    protected function _initialize()
    {
        parent::_initialize();
        if(!UserStatus::isLogin()) {
            $this->redirect("Index/login");
        }

        $auth = false;
        foreach ($this->getRole() as $role) {
            if(UserStatus::getRole() == $role) {
                $auth = true;
            }
        }
        if(!$auth) {
            $this->error("权限不够");
        }
    }

    protected abstract function getRole();
}